import React,{useState} from "react";

// useState() 只接收一个参数 这个参数是初始的state 
// useState返回一个数组 
// 数组的第一个元素是state的当前值 第二个元素是一个函数 用来替换原来的state值

function App() {
// console.log(useState(0));
// useState(0);
const [count,setCount] = useState(0)
const [isHot,setIshot] = useState(true)
const [person,setPerson]= useState(['张蔷','王心凌','钟欣潼','于文文'])
const setCounthandel = () => {
  setCount(count + 1);
}
const setIshothandel = () => {
  setIshot(!isHot);
}
const setPersonhandel = () => {
  setPerson([...person,'xxx'])
}
  return (
    <div>
      <h1>我今天吃了 {count} 碗饭</h1>
      <button onClick = {setCounthandel}>更新</button>
      <h1>今天天气怎么样</h1>
      <p>{isHot?'热啊':'冷啊'}</p>
      <button onClick={setIshothandel}>更换天气</button>
      <ul>
        {person.map(item=>{
          return ( <li>{item}</li>)
        })}
      </ul>
      <button onClick = {setPersonhandel}>添加成员</button>

    </div>
  );
}

export default App;

